<?php
namespace app\home\controller;
use app\common\controller\Homebase;
use \think\Db;
use \think\Request;

// +----------------------------------------------------------------------
// | XpCms
// +----------------------------------------------------------------------
// | Copyright (c) 2021-2099
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Mercurio（Xp） <725668993@qq.com>
// +----------------------------------------------------------------------

/*
** 前台表单提交处理
*/

class Message extends Homebase {
    private static $_form 	= null; // 数据表对象
    private static $_message 	= null; // 数据表对象
	
	// 优先加载
	public function  _initialize() {
		parent::_initialize();
		// 实例化数据表模型
		self::$_form = Db::name('Form');
		self::$_message = Db::name('Message');
		
	}
	
	public function index()
	{
	    if(request()->isPost()) {
	        $data = input();
	        $data['create_time'] = time();
	        $mid = self::$_message->insertGetId($data);
	        if($mid){
	            echo "<script>alert('提交成功！');history.go(-1);</script>";
	        }
	    }else{
	        echo "<script>alert('提交失败，请使用POST方式提交！')</script>";
	    }
	}
	
}
